<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model layout="inline" ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="批量价格值" prop="price">
              <a-input-number v-model="model.price" placeholder="请输入价格值" :precision="3" style="width: 100%" />
            </a-form-model-item>
            <a-form-model-item label="批量挂号费" prop="registerFee">
              <a-input-number v-model="model.registerFee" placeholder="请输入挂号费" :precision="3" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
export default {
  name: 'LogisticsProductFormModalForm',
  components: {},

  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        registerFee: [{ required: true, message: '请输入挂号费' }],
        price: [{ required: true, message: '请输入价格值' }],
      },
      columns: [],
      url: {},
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    add() {
      this.edit(this.modelDefault)
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
    },
    submitForm() {
      this.$refs.form.validate((valid) => {
        if(valid){
          this.$emit('ok', this.model);
        }
      })
    },
  },
}
</script>